Skip to content

fix(blocks): resolve variable display in mothership resource preview#4226

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/variable-selector-hydration
Apr 18, 2026
Merged

fix(blocks): resolve variable display in mothership resource preview#4226
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/variable-selector-hydration

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Variables block showed empty assignments in mothership resource preview but worked on the actual canvas
  • currentWorkflowId was read from URL params, which don't include workflowId in the mothership route
  • Fall back to activeWorkflowId from the workflow registry for embedded contexts

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Variables block showed empty assignments in the embedded workflow preview
because currentWorkflowId was read from URL params, which don't contain
workflowId in the mothership route. Fall back to activeWorkflowId from
the workflow registry.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 18, 2026 5:22pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 18, 2026

PR Summary

Low Risk
Low risk, localized change to ID resolution logic for embedded/preview routes; main risk is using the wrong workflow ID in edge cases where both URL params and registry state disagree.

Overview
Fixes workflow block previews in embedded/mothership routes by resolving currentWorkflowId from URL params or falling back to activeWorkflowId from the workflow registry (still using empty strings in sandbox mode).

This ensures downstream workflow-scoped queries (e.g., variable hydration and other block metadata lookups) receive a valid workflow ID even when workflowId is not present in the route.

Reviewed by Cursor Bugbot for commit 4efea0d. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 18, 2026

Greptile Summary

This PR fixes a bug where the Variables block showed empty assignments in the Mothership resource preview. The root cause was that currentWorkflowId was derived exclusively from URL params (params.workflowId), which are absent in the Mothership route — the fix falls back to activeWorkflowId from the workflow registry, with a final || '' guard to preserve the string type.

Confidence Score: 5/5

Safe to merge — minimal, targeted fix with no side effects on the existing canvas path.

Single-line change with a clear fallback chain; the previous type-widening concern from the thread is resolved by the || '' guard; no new P0/P1 findings identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx Moves currentWorkflowId derivation after useBlockVisual (which provides activeWorkflowId) and adds a registry fallback + empty-string guard to fix Mothership context; type-safe and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[WorkflowBlock renders] --> B{isSandbox?}
    B -- Yes --> C[currentWorkflowId = '']
    B -- No --> D{params.workflowId available?}
    D -- Yes --> E[currentWorkflowId = params.workflowId]
    D -- No e.g. Mothership route --> F{activeWorkflowId from registry?}
    F -- Yes --> G[currentWorkflowId = activeWorkflowId]
    F -- No --> H[currentWorkflowId = '' disables workspace-scoped queries]
    C --> I[Pass to useWebhookInfo / useScheduleInfo / SubBlockRow]
    E --> I
    G --> I
    H --> I
Loading

Reviews (2): Last reviewed commit: "fix(blocks): narrow currentWorkflowId to..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4efea0d. Configure here.

@waleedlatif1 waleedlatif1 merged commit 28b4c4c into staging Apr 18, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/variable-selector-hydration branch April 18, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant